home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-03-12 | 2.4 KB | 107 lines | [TEXT/PJMM] |
- {Rutin för att skapa text-faces för SAT. Skall användas i Drömspelet, för scrollande deltagarlista.}
-
- {A procedure for creating a face from a string. It uses the font, size and color from the current port.}
-
- unit FaceFromText;
- interface
- uses
- {$IFC UNDEFINED THINK_PASCAL}
- Types, QuickDraw, Memory, Resources, ToolUtils, Fonts, QuickDrawText,
- {$ENDC}
- SAT;
-
- function FaceFromText (myString: Str255; shadow: Integer): FacePtr;
-
- implementation
-
- function FaceFromText (myString: Str255; shadow: Integer): FacePtr;
- var
- theTextFace: FacePtr;
- r: Rect;
- height, width: Integer;
- var
- info: FontInfo;
- txFont: INTEGER;
- txFace: Style;
- txSize: INTEGER;
- txColor: RGBColor;
- txColor2: Longint;
- savePort: SATPort;
- begin
- SATGetPort(savePort);
- {Get font etc from the current port.}
- GetFontInfo(info);
- width := StringWidth(myString) + shadow;
- height := info.ascent + info.descent + shadow;
-
- {$IFC UNDEFINED THINK_PASCAL}
- txFont := qd.thePort^.txFont;
- txSize := qd.thePort^.txSize;
- txFace := qd.thePort^.txFace;
- {$ELSEC}
- txFont := thePort^.txFont;
- txSize := thePort^.txSize;
- txFace := thePort^.txFace;
- {$ENDC}
-
- if gSAT.colorFlag then
- GetForeColor(txColor)
- else
- {$IFC UNDEFINED THINK_PASCAL}
- txColor2 := qd.thePort^.fgColor;
- {$ELSEC}
- txColor2 := thePort^.fgColor;
- {$ENDC}
-
- {Create the face}
- SetRect(r, 0, 0, width, height);{}
- theTextFace := SATNewFace(r);
-
- SATSetPortFace(theTextFace);
- {Set up the face-port with the parameters we got above}
- TextFont(txFont);
- TextSize(txSize);
- TextFace(txFace);
-
- if gSAT.colorFlag then
- RGBForeColor(txColor)
- else
- ForeColor(txColor2);
-
- EraseRect(theTextFace^.iconMask.bounds);
- {Draw shadow, if any}
- if shadow <> 0 then
- begin
- MoveTo(shadow, info.ascent + shadow);
- ForeColor(blackColor);
- DrawString(myString);
- end;
- {Draw text}
- if gSAT.colorFlag then
- RGBForeColor(txColor)
- else
- ForeColor(txColor2);
- MoveTo(0, info.ascent);
- DrawString(myString);
- {Set the forecolor to black before leaving!}
- ForeColor(blackColor);
- {Draw the mask!}
- SATSetPortMask(theTextFace);
- TextFont(txFont);
- TextSize(txSize);
- TextFace(txFace);
- EraseRect(theTextFace^.iconMask.bounds);
- MoveTo(0, info.ascent);
- DrawString(myString);
- if shadow <> 0 then
- begin
- MoveTo(shadow, info.ascent + shadow);
- DrawString(myString);
- end;
- {Set back the port!}
- SATSetPort(savePort);
- SATChangedFace(theTextFace);
- FaceFromText := theTextFace;
- end;
-
- end.